<?php
# User session management
require_once('includes/user_manage.php');

	$user->order=new order();
	$user->order->user_id=$user->id;
	$user->order->db_get_last(">0");
	if ($user->order->id) {
		$user->order->db_load();
		$user->order->db_load_items();
		$cartPrice=0;
		foreach ($user->order->items as $item) {
			$cartPrice+=$item->price * $item->quantity;
		}
		$user->order->subTotal=$cartPrice;
		$user->order->payment=new payment();
		$user->order->payment->method=new payment_method();
		$user->order->payment->method->id=$user->order->payment_method_id;
		$user->order->payment->method->db_load();
		$user->order->delivery=new delivery();
		$user->order->delivery->phone=$user->order->phone; 
		if ($user->order->sec_phone) $user->order->delivery->sec_phone=$user->order->sec_phone;
		$user->order->delivery->shipping_type=new shipping_type();
		$user->order->delivery->shipping_type->id=$user->order->shipping_type_id;
		$user->order->delivery->shipping_type->db_load();
		$user->order->delivery->address=new address();
		if ($user->order->address_id) { 
			$user->order->delivery->address->id=$user->order->address_id;
		}
		else {
			$user->order->delivery->address->id=$user->address_id;
		}
		$user->order->delivery->address->db_load();
		$user->order->delivery->address->country=new country();
		$user->order->delivery->address->country->id=$user->order->delivery->address->country_id;
		$user->order->delivery->address->country->db_load();
		$user->order->delivery->address->zone=new zone();
		$user->order->delivery->address->zone->id=$user->order->delivery->address->zone_id;
		$user->order->delivery->address->zone->db_load();
		$_SESSION["ser_user"]=serialize($user);
?>

<p>A continuación le mostramos el último pedido que ha realizado.</p>

<?php
		include($server->get_path_name("last_order.php"));
	}
	else {
?>
<div class="note">
    <p>No tiene notificaciones.</p>
</div>
<?php
	}
?>